<template>
	<view class="u-rela">
		<!-- tab切换 -->
		<!-- <u-tabs height="100" font-size="34" active-color="#000000" inactive-color="#999999" bar-width="80"
			bar-height="14" :bar-style="{borderRadius:'14rpx',backgroundColor:'#07C160',bottom:'20rpx',zIndex:'0'}"
			:active-item-style="{zIndex:1}" :list="list" :is-scroll="false" :current="current" @change="change">
		</u-tabs> -->
		<!-- 职位列表 -->
		<div class="job-item" v-for="(item,index) in jobList" :key="index">
			<view class="title">{{item.title}}</view>
			<view class="u-flex label-wrap">
				<text v-for="(item2,index2) in item.tag" :key="index2">{{item2}}</text>
			</view>
			<view class="u-flex u-m-t-28">
				<image class="icon-7"
					src="https://nmlwx.sowreap.cn/nongmuWeChatImage/static/images/recruit/icon-7.png"
					mode="widthFix"></image>
				<text class="u-font-24 u-content-color">{{ item.company_name }}</text>
			</view>
			<view class="salary">{{item.salary}}</view>
			<div class="u-flex u-row-right u-m-t-30">
				<div class="btn btn-gray" @click="del_recruit_delJob(item.job_id)">删除岗位</div>
				<div class="btn btn-green u-m-l-20" @click="tofbzw(item)">管理岗位</div>
			</div>
		</div>

	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				list: [{
					name: '在招职位'
				}, {
					name: '全职'
				}, {
					name: '兼职'
				}],
				current: 0,
				jobList: [
				// 	{
				// 		name: '环保技术员',
				// 		salary: '5K~7.5K',
				// 		label: ["岗位标签", "岗位标签", "岗位标签"],
				// 		company: '广州微碳科技有限公司',
				
				// 	},
				// 	{
				// 		name: '行政文员',
				// 		salary: '4K',
				// 		label: ["岗位标签", "岗位标签", "岗位标签"],
				// 		company: '广州微碳科技有限公司'
				// 	},
				// 	{
				// 		name: '行政助理',
				// 		salary: '3.5K',
				// 		label: ["岗位标签", "岗位标签", "岗位标签"],
				// 		company: '广州微碳科技有限公司'
				// 	},
				],
				
				dataList:[],
			}
		},
		onLoad() {
			// 公司详情
			this.get_recruit_companyDetails()
		},
		onPullDownRefresh() {
			// 公司详情
			this.get_recruit_companyDetails()
		},
		methods: {
			change(index) {
				this.current = index;
			},
			
			// 公司详情
			get_recruit_companyDetails(){
				uni.showLoading({
					title: '加载中...'
				});
				this.$http({
					url:this.api.recruit_companyDetails,
					method:'GET'
				}).then(res=>{
					if(res.code == 1){
						uni.hideLoading();
						uni.stopPullDownRefresh();
						this.dataList = res.data
						
						this.get_recruit_recruitList(res.data.company_id)
					}
				})
			},
			
			// 岗位列表,此处需要传company_id,展示我的企业的招聘信息
			get_recruit_recruitList(company_id){
				uni.showLoading({
					title: '加载中...'
				});
				this.$http({
					url:this.api.recruit_recruitList,
					method:'GET',
					data:{
						company_id
					}
				}).then(res=>{
					if(res.code == 1){
						uni.hideLoading();
						uni.stopPullDownRefresh();
						this.jobList = res.data.list
					}
				})
			},
			
			// 删除岗位
			del_recruit_delJob(job_id){
				uni.showLoading({
					title: '删除中...'
				});
				this.$http({
					url:this.api.recruit_delJob,
					method:'POST',
					data:{
						job_id
					}
				}).then(res=>{
					if(res.code == 1){
						uni.showToast({
							icon:'success',
							title:"删除成功!",
							duration:2000
						})
						uni.hideLoading();
						uni.stopPullDownRefresh();
						// 公司详情
						this.get_recruit_companyDetails()
					}
				})
			},
			
			// 跳转到发布职位
			tofbzw(item){
				let jsonItem = JSON.stringify(item)
				uni.navigateTo({
					url:`/pages/recruit/worker/fbzw?jsonItem=${jsonItem}`
				})
			}
		}
	}
</script>

<style scoped lang="scss">	

	.job-item {
			width: 710rpx;
			margin: 20rpx auto;
			background: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			position: relative;
			box-sizing: border-box;
			box-shadow: 0px 0px 30px 0px rgba(8,14,95,0.1);
	
			.title {
				font-size: 34rpx;
				margin-bottom: 20rpx;
				font-weight: 700;
			}
	
			.icon-7 {
				width: 28rpx;
				height: 28rpx;
				margin-right: 10rpx;
			}
	
			.salary {
				position: absolute;
				top: 32rpx;
				right: 30rpx;
				color: #F7661E;
				font-size: 38rpx;
			}
	
			.label-wrap {
				text {
					border: 1px solid #DDDDDD;
					border-radius: 5rpx;
					padding: 10rpx;
					font-size: 20rpx;
					color: #999999;
					margin-right: 10rpx;
				}
			}
		}
		.btn{
			width: 160rpx;
			height: 70rpx;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
		}
		.btn-gray{
			background: #F3F3F3;
			border: 1px solid #DDDDDD;
			color: #999999;
		}
		.btn-green{
			background: #07C160;
			color: #FFFFFF;
		}
	

	
</style>

<style>
	page {
		padding: 0;
		background:#fff;
	}
</style>
